/**
 * 图表相关的类型定义
 */

export type ChartType = 'bar' | 'column' | 'line' | 'stepped-line' | 'mixed' | 'vertical-compare' | 'waterfall' | 'pie' | 'doughnut' | 'radar';

export type DisplayMode = 'table' | 'chart';

export interface ColumnDefinition {
  name: string;
  type: string;
}

export interface ChartAxisConfig {
  xAxis?: string;
  yAxis?: string[];
}

export interface ChartViewMode extends ChartAxisConfig {
  mode: DisplayMode;
  chartType: ChartType;
}

export interface ChartDataPoint {
  [key: string]: any;
}

export interface ChartDataset {
  label: string;
  data: number[];
  backgroundColor?: string | string[];
  borderColor?: string | string[];
  borderWidth?: number;
  type?: string;
  fill?: boolean;
  tension?: number;
  stack?: string;
}

export interface ChartData {
  labels: string[];
  datasets: ChartDataset[];
}

export interface ChartOptions {
  title?: string;
  xAxisLabel?: string;
  yAxisLabel?: string;
  responsive?: boolean;
  maintainAspectRatio?: boolean;
  height?: number;
  stacked?: boolean;
}

// 各图表的细粒度自定义配置
export interface LineChartCustomOptions {
  borderWidth?: number;
  tension?: number;
  fill?: boolean;
  pointRadius?: number;
  pointHoverRadius?: number;
  pointStyle?: 'circle' | 'cross' | 'crossRot' | 'dash' | 'line' | 'rect' | 'rectRounded' | 'rectRot' | 'star' | 'triangle';
}

export interface SteppedLineChartCustomOptions extends Omit<LineChartCustomOptions, 'tension' | 'fill'> {
  stepped?: true | 'before' | 'after' | 'middle';
}

export type ChartSpecificCustomOptions =
  | ({ type: 'line'; options: LineChartCustomOptions })
  | ({ type: 'stepped-line'; options: SteppedLineChartCustomOptions })
  | ({ type: 'bar'; options?: Record<string, any> })
  | ({ type: 'column'; options?: Record<string, any> })
  | ({ type: 'pie'; options?: Record<string, any> })
  | ({ type: 'doughnut'; options?: Record<string, any> })
  | ({ type: 'waterfall'; options?: Record<string, any> })
  | ({ type: 'mixed'; options?: Record<string, any> })
  | ({ type: 'vertical-compare'; options?: Record<string, any> });

